import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/route/application.dart';
import 'package:appflutterhomeschool/route/routes.dart';
import 'package:appflutterhomeschool/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///用户： ninetailedfox
///时间： 2020/6/24
///邮箱： 1037438704@qq.com
///功能： 信件页面底部组件


///信件详情页面
class LetterEditWidget extends StatelessWidget {
  final GestureTapCallback onTap, collectionOnTap;
  final bool collection;

  LetterEditWidget({this.onTap, this.collectionOnTap, this.collection});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(
        top: ScreenUtil().setWidth(25),
        bottom: ScreenUtil().setWidth(25),
        left: ScreenUtil().setWidth(35),
        right: ScreenUtil().setWidth(35),
      ),
      height: ScreenUtil().setWidth(143),
      child: Row(
        children: <Widget>[
          Expanded(
            child: GestureDetector(
              child: Container(
                color: Colors.transparent,
                child: TextField(
                  //是否显示密码
                  obscureText: false,
                  //是否禁用
                  enabled: false,
                  //是否获取焦点
                  autofocus: false,
                  controller: new TextEditingController(),
                  style: TextStyles.textDark43,
                  decoration: InputDecoration(
                    contentPadding: EdgeInsets.only(top: 5, left: 10),
                    fillColor: Colors.grey[100],
                    filled: true,
                    border: OutlineInputBorder(
                        borderRadius: BorderRadius.circular(50),
                        borderSide: BorderSide.none),
                    hintText: '回复信件',
                    counterText: "",
                    hintStyle: TextStyles.textGrey43,
                    prefixIcon: Image.asset(Utils.getImgPath("xinjian_huifu")),
                  ),
                ),
              ),
              onTap: onTap,
            ),
          ),
          GestureDetector(
            child: Padding(
              padding: EdgeInsets.only(left: 5),
              child: Image.asset(Utils.getImgPath(collection
                  ? "xinjian_shoucang_true"
                  : "xinjian_shoucang_false")),
            ),
            onTap: collectionOnTap,
          ),
          GestureDetector(
            child: Padding(
              padding: EdgeInsets.only(left: 5),
              child: Text("收藏", style: TextStyles.textGray35),
            ),
            onTap: collectionOnTap,
          ),
        ],
      ),
    );
  }
}

///信件顶部系统通知
class LetterTopWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(ScreenUtil().setWidth(35)),
      child: Material(
        elevation: 5.0,
        color: Colors.white,
        shadowColor: Colors.grey.withOpacity(0.5),
        borderRadius: BorderRadius.circular(15),
        child: InkWell(
          borderRadius: BorderRadius.circular(15),
          child: Container(
            decoration: new BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(15)),
            ),
            height: ScreenUtil().setWidth(174),
            width: double.maxFinite,
            margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(35),
                ScreenUtil().setWidth(31),
                ScreenUtil().setWidth(35),
                ScreenUtil().setWidth(31)),
            child: Row(
              children: <Widget>[
                Image.asset(Utils.getImgPath("xitongtongzhi")),
                SizedBox(width: ScreenUtil().setWidth(35)),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text("系统通知", style: TextStyles.textDark43),
                      Text("您的入班申请被拒绝了", style: TextStyles.textGray30),
                    ],
                  ),
                )
              ],
            ),
          ),
          onTap: () {
            Application()
                .navigatePushToPage(context, Routes.systemNotificationPage, {});
          },
        ),
      ),
    );
  }
}




///消息列表
class LetterListUserWidget extends StatelessWidget {

  List list = [
    {
      "name":"王老师",
      "image":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597352874560&di=1f0f9f94316f3c0f8518f646329ad3b7&imgtype=0&src=http%3A%2F%2Fpic29.nipic.com%2F20130527%2F8786105_134847292000_2.jpg"
      ,"banji":"高年一班~数学",
      "content":"期中模拟测试成绩",
      "bottom":"本次期中模拟测试的数学成绩,请查看！"
    },
    {
      "name":"李老师",
      "image":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597352874561&di=d32adfe3ac9e2b7b29481027239e7fa7&imgtype=0&src=http%3A%2F%2Fwww.wndhw.com%2Fmeinv%2Fzipai%2Fimages%2Fzp047t1.jpg"
      ,"banji":"高年一班~英语",
      "content":"第三次隋唐测试城市",
      "bottom":"本次期中模拟测试的英语成绩,请查看！"
    },
    {
      "name":"赵老师",
      "image":"https://timgsa.baidu.com/https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597352874556&di=1349eaf72c4b2d64409af46d7af2ba5d&imgtype=0&src=http%3A%2F%2Fdingyue.nosdn.127.net%2F3dI3RPSOI2eBbguqAvd3Tt8qeDZqVfBAIn2RRFktrpNe91512439810577.jpg"
      ,"banji":"高年一班~地理",
      "content":"地理地貌环境内容的知识点总接",
      "bottom":"这部分知识点对你学习地理环境有很大帮助,请查看！"
    }
  ];
  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      physics: NeverScrollableScrollPhysics(), //禁用滑动事件
      itemCount: list.length,
      shrinkWrap: true,
      itemBuilder: (context, index) {
        return GestureDetector(
            child: Container(
              height: ScreenUtil().setWidth(268),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(width: 1, color: Colors.grey[200]))),
              margin: EdgeInsets.fromLTRB(ScreenUtil().setWidth(35),
                  ScreenUtil().setWidth(35), ScreenUtil().setWidth(35), 0),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  CircleAvatar(
                    radius: ScreenUtil().setWidth(51.5),
                    backgroundImage: NetworkImage(
                        list[index]["image"]),
                  ),
                  SizedBox(width: ScreenUtil().setWidth(36)),
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Text.rich(TextSpan(children: [
                          TextSpan(
                              text: list[index]["name"], style: TextStyles.textDarkBold43),
                          TextSpan(
                              text: "\t\t${list[index]["banji"]}",
                              style: TextStyles.textBlue30),
                        ])),
                        SizedBox(width: ScreenUtil().setWidth(31)),
                        Text(
                          list[index]["content"],
                          style: TextStyles.textDark36,
                        ),
                        SizedBox(width: ScreenUtil().setWidth(25)),
                        Text(
                          list[index]["bottom"],
                          style: TextStyles.textGray30,
                        ),
                      ],
                    ),
                  ),
                  Container(
                    alignment: Alignment.topCenter,
                    child: Container(
                      width: 3,
                      height: 3,
                      decoration: BoxDecoration(
                          color: Colors.red,
                          borderRadius: BorderRadius.circular(5)),
                    ),
                  ),
                ],
              ),
            ),
            onTap: () {
              Application()
                  .navigatePushToPage(context, Routes.letterDetailsPage, {});
            });
      },
    );
  }
}
